<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
<meta charset="utf-8" />
<title>商品管理 - 走势数据</title>
<?php include($this->c['_homes']['_viewsHome'].'/_global/_head.php');?>
</head>
<!-- BEGIN BODY -->
<body class="page-header-fixed page-sidebar-fixed">
<!-- BEGIN HEADER -->
<?php include($this->c['_homes']['_viewsHome'].'/_global/head.php');?>
<!-- END HEADER -->
<div class="clearfix"></div>
<!-- BEGIN CONTAINER -->
<div class="page-container" > 
  <!-- BEGIN HORIZONTAL MENU PAGE SIDEBAR1 -->
  <?php include($this->c['_homes']['_viewsHome'].'/_global/menu.php');?>
  <!-- END BEGIN HORIZONTAL MENU PAGE SIDEBAR --> 
  <!-- BEGIN PAGE --> 
  <div class="page-content"> 
    <!-- BEGIN PAGE HEADER-->
    <div class="row">
      <div class="col-md-12"> 
        <!-- BEGIN PAGE TITLE & BREADCRUMB-->
        <h3 class="page-title"> 走势数据</h3>
        <ul class="page-breadcrumb breadcrumb">
          <li> <i class="icon-home"></i> <a href="/manage">后台</a> <i class="icon-angle-right"></i> </li>
          <li> 商品管理 <i class="icon-angle-right"></i> </li>
          <li><a href="/goods/goodslist">商品列表</a><i class="icon-angle-right"></i></li>
          <li>走势数据</li>
        </ul>
        <!-- END PAGE TITLE & BREADCRUMB--> 
      </div>
    </div>
    <!-- END PAGE HEADER--> 
    <!-- BEGIN DASHBOARD STATS -->
    <div class="row">
           <div class="col-md-12">
            <form method="get" role="form" action="" onSubmit="return chkfrm();">
			<input type="hidden" name="goods_id" value="<?=$this->data['goods_id'];?>">
            <div class="col-md-3">
                    <div class="input-group input-medium date date-picker" data-date="<?php echo date("Y-m-d");?>" data-date-format="yyyy-mm-dd" data-date-viewmode="years" data-date-minviewmode="months" style="float:left;">
                      <input class="form-control" readonly type="text" placeholder="开始时间" name="start_time" value="<?php if(isset($_GET['start_time'])){echo $_GET['start_time'];}else{echo '' ;} ?>">
                      <span class="input-group-btn">
                      <button type="button" class="btn default date-set"><i class="icon-calendar"></i></button>
                      </span> </div>
                  </div>
                  <div class="col-md-3">
                  <div class="input-group input-medium date date-picker" data-date="<?php echo date("Y-m-d");?>" data-date-format="yyyy-mm-dd" data-date-viewmode="years" data-date-minviewmode="months">
                      <input class="form-control" readonly type="text" placeholder="结束时间" name="end_time" value="<?php if(isset($_GET['end_time'])){echo $_GET['end_time'];}else{echo '' ;} ?>">
                      <span class="input-group-btn">
                      <button type="button" class="btn default date-set"><i class="icon-calendar"></i></button>
                      </span> </div>
                  </div>
                  <div class="col-md-1">
                    <input type="submit" value="搜索" class="btn blue btn-block">
                  </div>
            </form>
         </div>
       </div>
    <div class="row">
      <div class="col-md-12 col-sm-12">
      <div id="container_order" style="width:100%;height:400px;margin-top:30px;">数据加载中...</div>
      </div>
    </div>
  </div>
  <!-- END PAGE --> 
</div>
<!-- END CONTAINER -->
<?php include($this->c['_homes']['_viewsHome'].'/_global/_footer.php');?>
<script type="text/javascript" src="/style/chart/highcharts.js"></script>
<script type="text/javascript" src="/style/chart/exporting.js"> </script>
<!-- BEGIN PAGE LEVEL SCRIPTS --> 
<script src="/style/assets/scripts/app.js" type="text/javascript"></script> 
<!-- END PAGE LEVEL SCRIPTS --> 
<script>
jQuery(document).ready(function() {    
   App.init();

   if (jQuery().datepicker) {
	      $('.date-picker').datepicker({
	          rtl: App.isRTL(),
	          autoclose: true
	      });
	      $('body').removeClass("modal-open"); // fix bug when inline picker is used in modal
	    } 
});

$(function () {
	 $('#container_order').highcharts({
         chart: {
             zoomType: 'xy'
         },
         title: {
             text: '<?=$this->data['goods_name'];?>库存与销售额走势'
         },
         subtitle: {
             text: '<?=$this->chart['start'];?>~<?=$this->chart['end'];?>'
         },
         credits: {
         	enabled:false // 禁用版权信息
         },
         xAxis: [{
         	categories:[<?php if($this->chart['date']){ foreach ($this->chart['date'] as $k=>$v){
         		echo "'".$v."',";
         	} }?>],
             crosshair: true
         }],
         yAxis: [{ // Primary yAxis
             labels: {
                 format: '{value}',
                 style: {
                     color: Highcharts.getOptions().colors[1]
                 }
             },
             title: {
                 text: '数量',
                 style: {
                     color: Highcharts.getOptions().colors[1]
                 }
             }
         }],
         tooltip: {
             headerFormat: '<span>日期：{point.key}</span><br/>',
             shared: true,
             useHTML: true
         },
         plotOptions: {
             column: {
                 pointPadding: 0.2,
                 borderWidth: 0,

             }
         },
         series: [{
             name: '增加库存',
             type: 'spline',
             data:  [<?php if($this->chart['date']){ foreach ($this->chart['date'] as $k=>$v){
				 if($this->chart['data'][1][$v]) echo $this->chart['data'][1][$v].",";
				 else echo "0,";
         	} }?>],
             tooltip: {
                 valueSuffix: ''
             }
         },{
             name: '报损数量',
             type: 'spline',
             data:  [<?php if($this->chart['date']){ foreach ($this->chart['date'] as $k=>$v){
				 if($this->chart['data'][2][$v]) echo $this->chart['data'][2][$v].",";
				 else echo "0,";
         	} }?>],
             tooltip: {
                 valueSuffix: ''
             }
         },{
             name: '销售数量',
             type: 'spline',
             data:  [<?php if($this->chart['date']){ foreach ($this->chart['date'] as $k=>$v){
				 if($this->chart['data'][3][$v]) echo $this->chart['data'][3][$v].",";
				 else echo "0,";
         	} }?>],
             tooltip: {
                 valueSuffix: ''
             }
         }]
     });
});
</script> 
<script>
function chkfrm(){
	var start_time = document.getElementById("start_time").value;
	var end_time = document.getElementById("end_time").value;
	start_time = start_time.replace(/-/g,'/');
	end_time = end_time.replace(/-/g,'/');
	var date_start_time = new Date(start_time);
	var date_end_time = new Date(end_time);
	if(date_start_time !="" && date_end_time != ""&& date_start_time > date_end_time){
         alert("开始时间不能大于结束时间");
         return false;
	}
}
</script>
<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>